<template>
  <div class="tabs">
    <div
      v-for="(item, index) in tabs"
      class="tab-item"
      :key="item"
      @click="itemClick(index)"
    >
      <span :class="{ active: currentIndex === index }">
        {{ item }}
      </span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    tabs: Array
  },
  data() {
    return {
      currentIndex: 0
    }
  },
  methods: {
    itemClick(index) {
      this.currentIndex = index
      let type = ''
      if (this.currentIndex == 0) type = 'new'
      if (this.currentIndex == 1) type = 'pop'
      if (this.currentIndex == 2) type = 'sell'
      this.$emit('change', type)
    }
  }
}
</script>

<style lang="less" scoped>
.tabs {
  background: white;
  height: 35px;
  display: flex;
  align-items: center;
  text-align: center;
  font-size: 12px;
  z-index: 999;
  .tab-item {
    flex: 1;
    .active {
      padding: 5px 0;
      border-bottom: 2px solid var(--theme-color);
    }
  }
}
</style>
